﻿
@{
    ViewBag.Title = "WxAccount";
}

<div class="wrapper wrapper-content animated fadeInUp">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>自定义菜单权限配置<small>（如果您开通了自定义菜单，请将<a target="_blank" href="http://mp.weixin.qq.com">微信公众平台</a>下的 AppId 与 AppSecret 配置在下方）</small></h5>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="form1">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">AppId</label>

                            <div class="col-sm-6">
                                <input type="text" id="AppId" name="AppId" value="@ViewBag.AppId" class="form-control"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">AppSecret</label>

                            <div class="col-sm-6">
                                <input type="text" id="AppSecret" name="AppSecret" value="@ViewBag.AppSecret" class="form-control"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" id="btn_Submit" type="button">保存</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@section Js{
    <script type="text/javascript">
        var validator = $("#form1").validate({
            rules: {
                AppId: {
                    required: true
                },
                AppSecret: {
                    required: true
                }
            },
            messages: {
                AppId: {
                    required: "请输入AppId"
                },
                AppSecret: {
                    required: "请输入AppSecret"
                }
            }
        });
        $(function() {
            //dataInit();
            $("#btn_Submit").click(function() {
                if (validator.form()) {
                    var parms = {
                        AppId: $.trim($("#AppId").val()),
                        AppSecret: $.trim($("#AppSecret").val())
                    }
                    $.post("/WxSet/WxAccountSave", parms, function (json) {
                        if (json.result == "success") {
                            layer.msg('保存成功', { icon: 1, time: 2000 });
                        } else {
                            layer.msg(json.msg, { icon: 5 , time: 2000});
                        }
                    }, "json");
                }
            });

        });

    </script>
}